<?php
/**
 * 添加单页
 */
namespace Admin\Controller;
use Admin\Controller\AdminController;
class PageController extends AdminController {
	//显示所有单页
    public function index(){
        $this->page= M('page')->select();
        $this->assign("title","单页列表");
    	$this->display();
    }
    //添加单页
    public function add(){
        $this->assign("title","添加页面");
        $this->display();
    }
    //添加单页处理表单
    public function addHandle(){
       $page = D('Page');
       if(!$page->create()){
            $this->error($page->getError());
       }else{
            $result = $page->add(I());
            $result ? $this->success("添加成功") : $this->error("添加失败");
       }

    }    
    //删除单页
    public function del(){
        p(I());

    } 
    //编辑单页
    public function edit(){
        $id  = I("get.id");
        $this->page=M('page')->where("id=".$id)->select();
        $this->assign("title","编辑页面");
    	$this->display();
    }
    //编辑单页
    public function editHandle(){
        $page = D('Page');
        if(!$page->create()){
            $this->error($page->getError());
        }else{
            $result = $page->save(I());
            $result ? $this->success("修改成功") : $this->error("修改失败");            
        }        
    }    
}